//
//  ViewController.m
//  AbstractFactory
//
//  Created by flannery on 2018/12/17.
//  Copyright © 2018年 flannery. All rights reserved.
//

#import "ViewController.h"
#import "AbstractFactory.h"
#import "FactoryProducer.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    
    //获取形状工厂
    AbstractFactory *shapeFactory = [FactoryProducer getFactory:@"SHAPE"];
    
    // 获取形状为Circle的对象
    id<Shape> shape1 = [shapeFactory getShape:@"CIRCLE"];

    // 调用Circle的draw方法
    [shape1 draw];
    
    //后去形状为Rectangel的对象
    id<Shape> shape2 = [shapeFactory getShape:@"RECTANGLE"];
    //调用Rectangle的draw
    [shape2 draw];
    
    //获取形状为Square的对象
    id<Shape> shape3 = [shapeFactory getShape:@"SQUARE"];

    // 获取Square的draw方法
    [shape3 draw];
    
    //获取颜色工厂
    AbstractFactory *colorFactory = [FactoryProducer getFactory:@"COLOR"];
    
    //获取颜色为Red的对象
    id<Color> color1 = [colorFactory getColor:@"RED"];
    [color1 fill];
    
    //获取颜色为Red的对象
    id<Color> color2 = [colorFactory getColor:@"Green"];
    [color2 fill];
    
    //获取颜色为Red的对象
    id<Color> color3 = [colorFactory getColor:@"BLUE"];
    [color3 fill];
}


@end
